﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using CommandLine;
using CommandLine.Text;

namespace FileListBuilder
{
        public sealed class Options
        {
            const char      TAG_SEPARATOR = '-';
            const char      CODE_SEPARATOR = '_';
            const string    FILE_SELECTOR = "*.pdf";
            const string    START_DIRECTORY = @"C:\GED";
            const string OUTPUT_FILENAME = "FileList";
            const string OUTPUT_FILE_FORMAT = "XLS";

            #region Standard Option Attribute
            [Option("f", "FileSelector",
                    Required = false,
                    HelpText = "pattern for selecting file ex: *.pdf")]
            public string FileSelector = FILE_SELECTOR;

            [Option("t", "TagSeparator",
                    Required = false,
                    HelpText = "Tag separator, example : PG-QGR-001-v1_nom du fichier.pdf, '-' is the Tag separator")]
            public char TagSeparator = TAG_SEPARATOR;

            [Option("c", "CodeSeparator",
                    Required = false,
                    HelpText = "Code separator, example : PG-QGR-001-v1_nom du fichier.pdf, '_' is the Tag separator")]
            public char CodeSeparator = CODE_SEPARATOR;

            [Option("d", "StartDirectory",
                    Required = false,
                    HelpText = @"Start directory for scanning. example : .\GED")]
            public string StartDirectory = START_DIRECTORY;

            [Option("o", "OutputFilename",
                    Required = false,
                    HelpText = "Output filename, for example : FileList.xml")]
            public string OutputFilename = OUTPUT_FILENAME;

            [Option("x", "FileFormat",
                    Required = false,
                    HelpText = "Output file format, XLS (default) or XML")]
            public string OutputFileFormat = OUTPUT_FILE_FORMAT;

            [Option("v", null,
                    HelpText = "Verbose level. Range: from 0 to 2.")]
            public int? VerboseLevel = null;

            #endregion

            #region Specialized Option Attribute
            
            [HelpOption(
                    HelpText = "Dispaly this help screen.")]
            public string GetUsage()
            {
                var help = new HelpText(Program._headingInfo);
                help.AdditionalNewLineAfterOption = true;
                help.Copyright = new CopyrightInfo(@"(c) 2010-2011 Fred Berton http://fberton.blogspot.com", 2010);
                help.AddPreOptionsLine("This is free software. You may redistribute copies of it under the terms of");
                help.AddPreOptionsLine("the MIT License <http://www.opensource.org/licenses/mit-license.php>.");
                help.AddPreOptionsLine(@"Usage: FileListBuilder -f *.* -o FileListe.xml -d .\GED -t - -c _ -x XLS");
                help.AddOptions(this);

                return help;
            }
            #endregion
        }
}
